package com.ww.basic

object VariableTypesExample {
  def main(args: Array[String]): Unit = {
    // 显式类型声明
    val explicitInt: Int = 42
    val explicitDouble: Double = 3.14
    val explicitString: String = "Hello, Scala!"
    val explicitBoolean: Boolean = true

    // 类型推断
    val inferredInt = 42 // Int
    val inferredDouble = 3.14 // Double
    val inferredString = "Hello, Scala!" // String
    val inferredBoolean = true // Boolean

    // 可变变量
    var mutableInt = 42
    println(s"初始化mutableInt: $mutableInt")
    mutableInt += 1
    println(s"更新后的mutableInt: $mutableInt")

    // 输出所有变量
    println(s"explicitInt: $explicitInt")
    println(s"inferredInt: $inferredInt")
    println(s"explicitDouble: $explicitDouble")
    println(s"inferredDouble: $inferredDouble")
    println(s"explicitString: $explicitString")
    println(s"inferredString: $inferredString")
    println(s"explicitBoolean: $explicitBoolean")
    println(s"inferredBoolean: $inferredBoolean")
  }
}
